package windows;



import java.awt.Container;
import java.awt.Font;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.WindowConstants;

import coordinators.Cordinator;


public class WindowAdministrator extends JFrame implements ActionListener,KeyListener
{
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private Container contContenedor;
	private JMenuBar mnbBarMain;

	private JMenu mnuFile;
	private JMenuItem mniExit;


	private JMenu mnuMan_Manageclient;
	private JMenuItem mniManageClient;

	private JMenu mnuManageInsimos;
	private JMenuItem mniManageInsumos;

	private JMenu mnuManageOrder;
	private JMenuItem mniManageOrder;

	private JMenu mnuCreateReport;
	private JMenuItem mniCreateReport;

	private JMenu mnuDistributeOrder;
	private JMenuItem mniDistributeOrder;

	private JButton btnExit;

	private JLabel lbllogo;
	private JLabel lblTitle;
	private JLabel lblNit;


	ImageIcon imglogo;

	Cordinator coordinador;

	public WindowAdministrator(WindowPrincipal superior)
	{
		
		// TODO Auto-generated constructor stub

		contContenedor = getContentPane();
		contContenedor.setLayout(null);

		//imglogo = new ImageIcon("fondo.jpg");

		mnbBarMain = new JMenuBar();
		setJMenuBar(mnbBarMain);

		mnuFile= new JMenu("Archivo");
		mniExit = new JMenuItem("Salir");
		mnuFile.add(mniExit);
		mnbBarMain.add(mnuFile);

		mnuMan_Manageclient = new JMenu("Cliente");
		mniManageClient = new JMenuItem("Gestionar Clientes");
		mnuMan_Manageclient.add(mniManageClient);
		mnbBarMain.add(mnuMan_Manageclient);

		mnuManageInsimos = new JMenu("Insumos");
		mniManageInsumos = new JMenuItem("Gestionar Insumos");
		mnuManageInsimos.add(mniManageInsumos);
		mnbBarMain.add(mnuManageInsimos);

		mnuManageOrder = new JMenu("Pedidos");
		mniManageOrder = new JMenuItem("Gestionar Pedidos");
		mnuManageOrder.add(mniManageOrder);
		mnbBarMain.add(mnuManageOrder);

		mnuCreateReport = new JMenu("Reporte");
		mniCreateReport = new JMenuItem("Generar Repostes");
		mnuCreateReport.add(mniCreateReport);

		mnbBarMain.add(mnuCreateReport);

		mnuDistributeOrder = new JMenu("Pedido");
		mniDistributeOrder = new JMenuItem("Distribuir pedidos");
		mnuDistributeOrder.add(mniDistributeOrder);

		mnbBarMain.add(mnuDistributeOrder);

		btnExit = new JButton("Salir");
		btnExit.setBounds(270,140,80,25);
		contContenedor.add(btnExit);

		lbllogo = new JLabel(imglogo);
		lbllogo.setBorder(BorderFactory.createBevelBorder(1));
		lbllogo.setBounds(20,20,160,160);
		contContenedor.add(lbllogo);

		lblTitle = new JLabel("Pasteleria Ing. soft");
		lblTitle.setFont(new Font("Times New Roman", 3, 25));
		lblTitle.setForeground(new java.awt.Color(0, 0, 153));
		lblTitle.setBounds(200,20,240,30);
		contContenedor.add(lblTitle);

		lblNit = new JLabel("NIT: 899.254.321");
		lblNit.setFont(new Font("Script MT Bold", 3, 18));
		lblNit.setForeground(new java.awt.Color(0, 0, 153));
		lblNit.setBounds(225,50,180,30);
		contContenedor.add(lblNit);

		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		this.addWindowListener(new WindowListener() 
		{
	        public void windowClosed(WindowEvent arg0) 
	        {
	            coordinador.ProcessCloseWindowAdministrator();
	        }
	        public void windowClosing(WindowEvent arg0) 
	        {
	        }
			public void windowActivated(WindowEvent e) 
			{
			}
			public void windowDeactivated(WindowEvent e) 
			{
			}
			public void windowDeiconified(WindowEvent e) 
			{
			}
			public void windowIconified(WindowEvent e) 
			{
			}
			public void windowOpened(WindowEvent e) 
			{
			}
		});
		
		setTitle("Administrador");
		setSize(470,250);
		setLocation(200,100);
		setResizable(false);

		mniExit.addActionListener(this);
		mniManageClient.addActionListener(this);
		mniManageInsumos.addActionListener(this);
		mniManageOrder.addActionListener(this);

		mniCreateReport.addActionListener(this);
		mniDistributeOrder.addActionListener(this);

		btnExit.addActionListener(this);
		btnExit.addKeyListener(this);
	}
	public void actionPerformed(ActionEvent evento)
	{
		if(evento.getSource()==mniManageClient)
		{
			coordinador.ProcessManageClient();
		}

		if(evento.getSource()==mniManageInsumos)
		{
			coordinador.ProcessManageInsumos();
		}

		if(evento.getSource()==mniManageOrder)
		{
			coordinador.ProcessManageOrder();
		}
		if(evento.getSource()==mniCreateReport)
		{
			coordinador.ProcessCreateReport();
		}
		if(evento.getSource()==mniDistributeOrder)
		{
			coordinador.ProcessDistributeOrder();
		}
		if(evento.getSource()==mniExit)
		{
			coordinador.ProcessCloseWindowAdministrator();
		}

		if(evento.getSource()==btnExit)
		{
			coordinador.ProcessCloseWindowAdministrator();
		}
	}


	public void keyTyped(KeyEvent e)
	{

	}

	public void keyReleased(KeyEvent e)
	{
		
	}

	public void keyPressed(KeyEvent e)
	{

	}
	public void setCoordinador(Cordinator c)
	{
		coordinador = c;
	}
}
